//
//  ColorWheelVC.m
//  01-UIPopoverController
//
//  Created by Zed on 8/10/2015.
//  Copyright © 2015 itcast. All rights reserved.
//

#import "ColorWheelVC.h"
#import "UIImage+GetColor.h"

@interface ColorWheelVC ()

@property (weak, nonatomic) IBOutlet UIButton *colorSeleteView;


@end

@implementation ColorWheelVC

- (instancetype)init
{
#warning 调色盘view的来源在这里写
 
    return [[UIStoryboard storyboardWithName:@"ColorWheelVC" bundle:nil] instantiateViewControllerWithIdentifier:NSStringFromClass(self.class)];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    // 弹出窗口大小
    self.preferredContentSize = self.colorSeleteView.bounds.size;
    // 禁止colorBtn的交互
    self.colorSeleteView.userInteractionEnabled = NO;
}

// 拿到点击的点的位置
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = touches.anyObject;
    CGPoint point = [touch locationInView:self.colorSeleteView.imageView];
    UIColor *color = [self.colorSeleteView.imageView.image pixelColorAtLocation:point];
    
    // 通知代理
    if ([self.delegate respondsToSelector:@selector(colorWheelVC:didSelctedColor:)]) {
        [self.delegate colorWheelVC:self didSelctedColor:color];
    }
}

@end













